<?php
/**
 * 用户验证器
 */

namespace app\validate;

use think\Validate;

class User extends Validate
{
    protected $rule = [
        'phone|用户电话' => 'require|max:11|number|min:11|mobile',
        'invite_code|邀请码' => 'require|max:6',
        'card_num|身份证' => 'require',
        'username|姓名' => 'require',
        'code|手机验证码' => 'require|max:6|number',
        'password|用户密码' => 'require|length:6,16',
    ];

    protected $message = [
        'phone.require' => '手机号不能为空',
        'phone.max' => '手机号码最大为11位',
        'phone.min' => '手机号码必须为11位',
        'phone.number' => '手机号码必须为数字',
        'phone.mobile' => '手机号错误',
        'invite_code.require' => '邀请码不能为空',
        'invite_coe.max' => '邀请码最大为6位',
        'code.require' => '手机验证码不能为空',
        'code.max' => '手机验证码最大位6位',
        'code.number' => '手机验证码必须位数字',
        'password.require' => '密码不能为空',
        'password.length' => '密码必须位6位到16位之间',
    ];

    protected $scene = [
        'register' => ['phone', 'invite_code', 'code'], // 注册
        'login' => ['phone', 'password'], // 账号密码登录
        'fastLogin' => ['phone', 'code'], // 手机验证码登录
        'RealName' => ['card_num', 'username'], // 手机验证码登录
    ];
}

